<html><head><title>DatabaseUpdate</title></head>
<body bgcolor="#EFF1F0" link="#3A3966" vlink="#000000" alink="#000000">
<font face="Verdana, sans-serif" size="2"><p align="center"><b><font size="4">DatabaseUpdate()</font></b></p>
<p><b>Syntax</b></p><blockquote>
Result = <font color="#3A3966"><b>DatabaseUpdate</b></font>(#Database, Request$)</blockquote>

</blockquote>
<b>Description</b><br><blockquote>

Executes a modification query on the given database. This command doesn't return 
any record. To perform a 'SELECT' like query, use <a href="databasequery.html">DatabaseQuery()</a>. 

</blockquote><p><b>Parameters</b></p><blockquote>
<style type="text/css">
table.parameters { border-spacing: 0px; border-style: none; border-collapse: collapse; }
table.parameters td { border-width: 1px; padding: 6px; border-style: solid; border-color: gray; vertical-align: top; font-family:Arial; font-size:10pt; }
</style>
<table width="90%" class="parameters">
<tr><td width="10%"><i>#Database</i></td>
<td width="90%"> 
The database to use. 

</td></tr>
<tr><td><i>Request$</i></td>
<td> 
The query to execute. 

</td></tr>
</table>
</blockquote><p><b>Return value</b></p><blockquote>

Returns nonzero if the query was successful or zero if it failed (due to a SQL error or a badly-formatted query). 

</blockquote><p><b>Remarks</b></p><blockquote>

This function is similar to <a href="databasequery.html">DatabaseQuery()</a> but is independent from the 
<a href="nextdatabaserow.html">NextDatabaseRow()</a> function. Therefore it's not possible to do a 'SELECT' like query 
with this function. This function is useful for updating records in the database. 
In the event of an error, the error text can be retrieved with <a href="databaseerror.html">DatabaseError()</a>. 
<br>
<br>
The update request can contain place holders for bind variables. Such variables must be set before 
calling the function using <a href="setdatabasestring.html">SetDatabaseString()</a>, <a href="setdatabaselong.html">SetDatabaseLong()</a> etc. After executing the update, 
the bound variables are cleared and have to be set again for future calls. The syntax for specifying 
bind variables in SQL is dependent on the database. The example below demonstrate the syntax. 

</blockquote><p><b>Example</b></p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#3A3966">; First, connect to a database with an employee table</font>
  <font color="#3A3966">;</font>
  <b><font color="#3A3966">If</font></b> <font color="#3A3966">DatabaseQuery</font>(<font color="#924B72">#Database</font>, &quot;SELECT * FROM employee&quot;) <font color="#3A3966">; Get all the records in the 'employee' table</font>
  
    <b><font color="#3A3966">While</font></b> <font color="#3A3966">NextDatabaseRow</font>(<font color="#924B72">#Database</font>) <font color="#3A3966">; Loop for each records</font>
      
      <font color="#3A3966">; Update the 'checked' field for each records, assuming the 'id' field is </font>
      <font color="#3A3966">; the first one in the 'employee' table</font>
      <font color="#3A3966">;</font>
<font color="#3A3966">      DatabaseUpdate</font>(<font color="#924B72">#Database</font>, &quot;UPDATE employee SET checked=1 WHERE id=&quot;+<font color="#3A3966">GetDatabaseString</font>(<font color="#924B72">#Database</font>, 0)) 
    <b><font color="#3A3966">Wend</font></b>
    
<font color="#3A3966">    FinishDatabaseQuery</font>(<font color="#924B72">#Database</font>)
  <b><font color="#3A3966">EndIf</font></b>
</font></pre>

</blockquote><p><b>Example:</b> Bind variables with SQLite and ODBC</p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#3A3966">; SQLite and ODBC shares the same syntax for bind variables. It is indicated by the '?' character</font>
  <font color="#3A3966">;</font>
<font color="#3A3966">  SetDatabaseLong</font>(0, 0, 1)
<font color="#3A3966">  SetDatabaseString</font>(0, 1, &quot;test&quot;)
<font color="#3A3966">  DatabaseUpdate</font>(0, &quot;UPDATE employee SET checked=? WHERE id=?&quot;)
</font></pre>

</blockquote><p><b>Example:</b> PostgreSQL</p><blockquote>

<pre><font face="Courier New, Courier, mono"size="2">  <font color="#3A3966">; PostgreSQL uses another syntax: $1, $2.. into the statement to indicate the undefined parameter</font>
  <font color="#3A3966">;</font>
<font color="#3A3966">  SetDatabaseLong</font>(0, 0, 1)
<font color="#3A3966">  SetDatabaseString</font>(0, 1, &quot;test&quot;)
<font color="#3A3966">  DatabaseUpdate</font>(0, &quot;UPDATE employee SET checked=$1 WHERE id=$2&quot;)
</font></pre>

</blockquote><p><b>See Also</b></p><blockquote>

<a href="databasequery.html">DatabaseQuery()</a> 
<a href="setdatabasestring.html">SetDatabaseString()</a>, <a href="setdatabaselong.html">SetDatabaseLong()</a>, <a href="setdatabasequad.html">SetDatabaseQuad()</a>, <a href="setdatabasefloat.html">SetDatabaseFloat()</a>, <a href="setdatabasedouble.html">SetDatabaseDouble()</a> 
<a href="setdatabaseblob.html">SetDatabaseBlob()</a>, <a href="setdatabasenull.html">SetDatabaseNull()</a> 

</Blockquote><p><b>Supported OS </b><Blockquote>All</Blockquote></p><center><- <a href=databasequery.html>DatabaseQuery()</a> - <a href="index.html">Database Index</a> - <a href="examinedatabasedrivers.html">ExamineDatabaseDrivers()</a> -><br><br>

</body></html>